/*
 *  PMRange.h
 *  PezMonkey
 *
 *  Created by Spence DiNicolantonio on 12/22/09.
 *  Copyright 2009 Necrosoft. All rights reserved.
 *
 */

#import "PMCore.h"


#pragma mark Type Definition

/**
 * Defines the PMRange type.
 */
typedef struct _PMRange {
	PMFloat min;
	PMFloat max;
} PMRange;


#pragma mark -
#pragma mark Static Inline Functions

/**
 * Constructs a PMRange structure with a given minimum and maximum limit.
 */
static inline PMRange PMRangeMake(PMFloat min, PMFloat max) {
	PMRange range;
	range.min = min;
	range.max = max;
	return range;
}

/**
 * Clamps a given PMfloat to a given PMRange.
 */
static inline PMFloat PMRangeClamp(PMFloat f, PMRange r){
	return PMFloatClamp(f, r.min, r.max);
}


#pragma mark -
#pragma mark Other Functions

/** 
 * Creates and returns an NSString object describing a given PMRange.
 */
static NSString* PMRangeToString(const PMRange range) {
	return [NSString stringWithFormat:@"(%0.3f, %0.3f)", range.min, range.max];
}